package com.ljsw.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ljsw.activity.R;
import com.ljsw.entity.pkentity.PKListinfoEntity;

import java.util.List;

/**
 * Created by lianchao on 2020/10/13.
 */

public class PKListInfoAdapter extends BaseAdapter {
    private List<PKListinfoEntity> LockID;
    private Context mContext;

    public PKListInfoAdapter(List<PKListinfoEntity> LockID, Context mContext) {
        super();
        this.LockID = LockID;
        this.mContext = mContext;
    }


    @Override
    public int getCount() {
        return LockID.size();
    }

    @Override
    public Object getItem(int position) {
        return LockID.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        PKListInfoAdapter.ViewHolder mviewHolder = null;
        if (mviewHolder == null) {
            mviewHolder = new PKListInfoAdapter.ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.pklistinfo_list_item, null, false);
            TextView tv = (TextView) convertView.findViewById(R.id.cardtext);
            TextView tvtime = (TextView) convertView.findViewById(R.id.PKtime);
            TextView tvstate = (TextView) convertView.findViewById(R.id.PKState);
            mviewHolder.tv = tv;
            mviewHolder.tvtime = tvtime;
            mviewHolder.tvstate = tvstate;
            convertView.setTag(mviewHolder);
        } else {
            mviewHolder = (PKListInfoAdapter.ViewHolder) convertView.getTag();
            convertView.setTag(mviewHolder);
        }
        mviewHolder.tv.setText(LockID.get(position).getPKNo());
        mviewHolder.tvtime.setText(LockID.get(position).getPKTime());
        mviewHolder.tvstate.setText(LockID.get(position).getPKState());
        return convertView;
    }


    class ViewHolder {
        private TextView tv;
        private TextView tvtime;
        private TextView tvstate;


    }
}
